<template>
  <div>
    Username:<input type="text" v-model="username">
    Password:<input type="password" v-model="password">
    <input type="button" value="创建" @click="reg">
  </div>
</template>

<script>
  export default {
    name: "Reg",
    data: function () {
      return {
        username: '',
        password: ''
      }
    },
    methods: {
      reg() {
        let formData = new FormData()
        formData.append('username', this.username);
        formData.append('password', this.password);
        this.axios({
          url: 'http://localhost:8000/myapp/reg/',
          method: 'post',
          data: formData
        }).then(res=>{
          if(res.data.code === 200){
            alert(res.data.data)
            this.$router.push({name:'Log'})
          }else {
            alert(res.data.data)
          }
        })
      }
    }
  }
</script>

<style scoped>

</style>
